<?

$salida = new stdClass();


// get info
$un = $_POST['usernamephp'];
$pw = $_POST["passwordphp"];
$db = $_POST["databasephp"];
$host = $_POST["hostphp"];
$query = $_POST["queryphp"];
$query = stripslashes($query);

//connect to the db
//$conn = mssql_connect("WSSSERVER", $user, $pswd)
$conn = mysqli_connect("".$host."", $un, $pw)
	or die("Couldn't connect to MYSQL Server on ".$host."");
	
//select a database to work with
$selected = mysqli_select_db($conn, "".$db."")
	or die("Couldn't open database ".$db."");

//execute the SQL query and return records
$sql= mysqli_query($conn, "".$query."") or die("query error: ".$conn->error);

while($row= mysqli_fetch_assoc($sql))
{
	//$row['comments']=utf8_encode($row['comments']);
	$salida->resultados[] = $row;
}

mysqli_close($conn);

print(json_encode($salida));

?>